home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amoszine 2
/
Amoszine 2.adf
/
MORE_SOURCE_CODE
/
Stars.AMOS
/
Stars.amosSourceCode
Wrap
AMOS Source Code
|
1992-02-26
|
3KB
|
63 lines
' ***************************************
' *** Going out with Stars ***
' *** ***
' *** By ***
' *** ***
' *** P A U L O V E R Y ***
' *** ***
' *** This uses integer maths only. ***
' *** ------- ***
' ***************************************
'
' Note: This program can easly be turned into a fast piece of
' machine code. As I have gone out of my way to use only
' integers and logical shifts, which CPU's are really only good at.
'
Set Buffer 64 : Hide : NUM_COLS=16
Screen Open 0,320,256,NUM_COLS,Lowres : Flash Off : Curs Off : Cls 0
N=64 : Rem number of stars
HOW_RANDOM=128
Dim SPEED(N),G(N),R(N),T(N),MX(N),MY(N)
Dim X(N),Y(N),C(N),OX(N),OY(N),RAN(HOW_RANDOM),S_RAN(HOW_RANDOM),TIME(HOW_RANDOM)
'
' Set grey shade colours.
For K=0 To NUM_COLS-1 : Colour K,(16/NUM_COLS*$111)*K : Next K
'
' How quick should stars speed up
For K=0 To N : C(K)=1 : SPEED(K)=2^Rnd(2)*NUM_COLS : Next K
'
LOC=0 : Rem array LOCation pointer
PRE_CALC=HOW_RANDOM-2 : Rem Offset for random number array.
'
' Speed up main routine by generating all random numbers now.
For K=0 To HOW_RANDOM : Rem larger number gives more variority.
RAN(K)=Rnd(128)-64
S_RAN(K)=2^Rnd(2)*16
TIME(K)=Rnd(20)+25
Next K
'
Do
For K=0 To N
' Speed up star.
Add MX(K),MX(K)/SPEED(K) : Add MY(K),MY(K)/SPEED(K)
' calculate new star position.
Add X(K),MX(K)/16 : Add Y(K),MY(K)/16 : Dec C(K)
If C(K)=0
Add LOC,1,0 To PRE_CALC : Rem Array lookup point
MX(K)=RAN(LOC)*16 : Rem new angle
MY(K)=RAN(LOC+2)*16 : Rem " "
X(K)=5120+MX(K) : Y(K)=4096+MY(K)
Rem 160*32=5120, 128*32=4096, centre dots.
SPEED(K)=S_RAN(LOC) : Rem New Speed.
C(K)=TIME(LOC) : Rem Counter for resetting stars.
R(K)=C(K)/NUM_COLS : Rem Colour fade out reset value.
T(K)=R(K) : Rem Colour fade out counter.
G(K)=0 : Rem Start with a black star.
End If
Dec T(K) : If T(K)=-1 Then Inc G(K) : T(K)=R(K)
Plot OX(K),OY(K),0 : Rem Remove old star
' Use large numbers & divide them down instead of using floats.
OX(K)=X(K)/32 : OY(K)=Y(K)/32
Plot OX(K),OY(K),G(K) : Rem plot new star
Next K
Loop